package main;

import java.io.*;

public class objFileWriter {

	public static void obj2file(String fileName, Object[] ob) {

		ObjectOutputStream oos;
		int count = 0;
		try {
			FileOutputStream fOut = new FileOutputStream(fileName);
			oos = new ObjectOutputStream(fOut);
			// write all of objects in array into file
			while (count < ob.length) {
				oos.writeObject(ob[count++]);
			}
			// fOut.write(count);
			oos.close();
		} catch (IOException e) {
			System.out.println("Khong tim thay file");
			e.printStackTrace();
		}
		return;
	}

	public static void obj2file(String fileName, Object ob) {

		ObjectOutputStream oos;

		try {
			FileOutputStream fOut = new FileOutputStream(fileName);
			oos = new ObjectOutputStream(fOut);
			// write an object into file
			oos.writeObject(ob);

			oos.close();
		} catch (IOException e) {
			System.out.println("Khong tim thay file");
			e.printStackTrace();
		}
		return;
	}
}
